import 'package:flutter/material.dart';

import 'util.dart';

extension ImgPath on String {
  String get imgPath {
    return 'assets/images/$this';
  }

  ///首页
  String get imgPathAppTab {
    return 'assets/images/appTab/$this';
  }

  ///首页
  String get imgPathCommon {
    return 'assets/images/common/$this';
  }

  ///首页
  String get imgPathHome {
    return 'assets/images/home/$this';
  }

  ///我的
  String get imgPathMe {
    return 'assets/images/me/$this';
  }

  ///登录注册
  String get imgPathLogin {
    return 'assets/images/login/$this';
  }

  ///版本
  String get imgPathVersion {
    return 'assets/images/version/$this';
  }
}

extension ImageLoadEx on Image {
  static Widget avater(
    String? url, {
    double? size,
    BoxFit fit = BoxFit.contain,
    bool isCircle = true,
    String? sex,
  }) {
    var isWoman = sex == '2' || sex == '女';
    var ph = isWoman ? 'avater_woman.png' : 'avater_man.png';
    return loadAvater(
      url: url,
      size: size ?? 60.r,
      fit: fit,
      isCircle: isCircle,
      placeholder: ph.imgPathMe,
    );
  }
}
